package com.github.baichuan.application.scaffold.rest.domain.organization;

import com.github.baichuan.application.scaffold.rest.domain.application.Application;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;

@Entity
@Getter
@Setter
public class Org {
    @Id
    private String uid;

    @ManyToOne
    @JoinColumn(name = "application_id")
    private Application application;

    @ManyToOne
    @JoinColumn(name = "tenant_id")
    private Tenant tenant;

    private String name;

    @ManyToOne
    @JoinColumn(name = "parent_uid")
    private Org parent;

    private String branch;

    public String topBranch(){
        return topUid() + ",";
    }

    public String topUid(){
        return branch.split(",")[0];
    }
}
